package reflection;

import com.backend.wechat.controller.HelloworldController;
import com.sun.org.apache.bcel.internal.util.ClassLoader;
import com.sun.org.apache.regexp.internal.RE;

/**
 * function
 * Created by lhlong on 2017/1/10.
 */
public class ReflectionUtil {

    private String obName;//对象名称,带包名

    public ReflectionUtil(String obName){
        this.obName = obName;
    }

    /**
     * 反射获得方法名称
     */
    public void refClassName(){
        Class aClass = ReflectionUtil.class;
        int modify = aClass.getModifiers();

        System.out.println("aClass's Name:"+aClass.getName()+"modifier:"+modify);
        Package aPackage = aClass.getPackage();

        //获得子类
        Class superclass = aClass.getSuperclass();
        //获得接口类
        Class[] interfaces = aClass.getInterfaces();
    }

    public void reflectionOB(){
         java.lang.ClassLoader loader =  HelloworldController.class.getClassLoader();

        try {
            Class aClass = loader.loadClass(this.obName);

            System.out.println("aClass.getName() = " + loader);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }



}
